package com.qunar.wan.service;

import com.qunar.wan.common_api.model.Comment;
import com.qunar.wan.common_api.model.Query;
import com.qunar.wan.common_api.model.Sort;
import com.qunar.wan.common_api.service.CommentService;
import com.qunar.wan.common_api.service.mapper.CommentMapper;
import com.qunar.wan.common_api.serializer.RowBounds;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * User: huiming.suo Date: 13-11-27 Time: 上午11:34
 */
@Service("commentService")
public class CommentServiceImpl extends BaseServiceImpl<Comment, CommentMapper> implements CommentService {

    // 查找条件actId，排序id逆序
    @Override
    public List<Comment> selectByActId(Integer actId, RowBounds rowBounds) {
        return selectByQuery(new Query().fill("actId", actId).addSort(new Sort("id", Sort.Order.DESC)), rowBounds);
    }

    @Override
    public int selectCount(Integer actId) {
        List<Comment> list = selectByQuery(new Query().fill("actId", actId));
        return list.size();
    }
}
